package com.genITeam.ria.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;


import com.genITeam.ria.exception.NGFException;
import com.genITeam.ria.vo.ThreadPostVo;

public class PostDAO {
	
    /**
     * savePost 
     * 
     * @param ThreadPostVo
     * 		 
     * @return void
     * @throws NGFException
     */  
	
	
	
	public void savePost(ThreadPostVo threadPostVo) throws NGFException{
		Session session=null;
		try {
			SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();			
			session = sessionFactory.openSession();		
			Transaction tx = session.beginTransaction();
			session.saveOrUpdate(threadPostVo);
			tx.commit();		     		
		   
		}catch (Exception e) {
			 session.close();
			throw new NGFException(e.getMessage());

		}finally{
		session.close();
		}
		

	}

}
